#!/bin/bash

set -e

DIR="$(cd "$(dirname "$0")" && pwd)"
# source $DIR/setenv.sh


export CICD_HOME=~/zsrd-cicd

export GIT_HOME=${CICD_HOME}/gogs
export JENKINS_HOME=${CICD_HOME}/jenkins
export MYSQL_HOME=${CICD_HOME}/mysql
export NEXUS_HOME=${CICD_HOME}/nexus

echo $JENKINS_HOME

mkdir -p $CICD_HOME

mkdir -p $JENKINS_HOME

# 重要：修改jenkins目录
chown -R 1000:1000 $JENKINS_HOME



if [ -n "$(docker-compose ps -q)"  ]
then
    echo "stopping existing CI/CD instance ..." 
    docker-compose down -v
fi

echo "starting CI/CD ..."
docker-compose up -d
